{% extends "master.html" %}
{% block subtitle %} - 零售管理 - 零售开单{% endblock %}
{% block extCSS %}
<style>
.form-horizontal .control-group{margin-bottom:3px;}
</style>
{% endblock %}
{% block extJS %}
<script>
$(function() {
    
})
</script>
{% endblock %}
{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
            <li><a href="{{url_for('bpRoot.view')}}">主面板</a></li>
            <li><a href="{{url_for('.view')}}">零售管理</a></li>
            <li class="active">零售单详情</li>
        </ol>
    </div>
    <div class='row'>
        <ul class="nav nav-tabs">
            <li class="active"><a href="#">零售单详情</a></li>
            <li><a href="{{url_for('.view', action='viewLog', id=so.id)}}">日志记录</a></li>
            <li><a href="{{url_for('.view', action='stamp', id=so.id)}}">打印</a></li>
        </ul>
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            {% if so.editable() %}
                <div class="btn-group"><a class="btn btn-default" href="{{url_for('.view', action='edit', id=so.id)}}">编辑</a></div>
            {% endif %}
            {% if so.approvable() %}
                <div class="btn-group"><a class="btn btn-primary" href="{{url_for('.view', action='approve', id=so.id)}}">审批通过</a></div>
            {% endif %}
            {% if so.deletable() %}
            <div class="btn-group"><a class="btn btn-danger" href="{{url_for('.view', action='delete', id=so.id)}}">删除</a></div>
            {% endif %}
        </div>
    </div>
    <div class="row form-horizontal form-view">
        <fieldset>
            <legend>零售单详情</legend>
            <div class='form3'>
                <div class="control-group">
                    <label class="control-label">付款方式</label>
                    <div class="controls">
                        {{ so.payterm }}
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">总价</label>
                    <div class="controls">{{ so.amount }}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">折后价</label>
                    <div class="controls">{{ so.realAmount }}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">实付</label>
                    <div class="controls">{{ so.payAmount }}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">找零</label>
                    <div class="controls">{{ so.refundAmount }}</div>
                </div>
            </div>
            <div class='form3'>
                <div class="control-group">
                    <label class="control-label">销售日期</label>
                    <div class="controls">{{ so.soldTime|fd }}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">店号</label>
                    <div class="controls">{{ shop.no }}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">员工</label>
                    <div class="controls">{{ so.createBy }}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">系统编号</label>
                    <div class="controls">{{ so.no }}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">会员</label>
                    <div class="controls">{{ so.member.no if so.member }}</div>
                </div>
            </div>
            <div class='form3'>
                <div class="control-group">
                    <label class="control-label">用途</label>
                    <div class="controls">{{so.usage}}</div>
                </div>
                <div class="control-group">
                    <label class="control-label">备注</label>
                    <div class="controls">{{so.remark}}</div>
                </div>
            </div>
        </fieldset>
    </div>
    <div class='row'>
        <label><strong>商品清单</strong></label>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th width='202px'>商品编号/名称</th>
                    <th width='200px'>数量</th>
                    <th width='130px'>单价(RMB)</th>
                    <th width='130px'>手工费(RMB)</th>
                    <th width='100px'>合计(RMB)</th>
                </tr>
            </thead>
            <tbody>
                {% for dtl in so.dtls %}
                <tr>
                    <td>
                        {{ mymacros.render_goto_popup_pdt(dtl.pdt, loop.first) }}
                        {{ dtl.pdtname }}
                    </td>
                    <td>
                        {% for ivtQtyObj in dtl.ivtQtyObjs -%}
                        <div class='btn-group'>
                            <a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>
                                {{ ivtQtyObj['qty'] }}&nbsp;<span class='caret'></span>
                            </a>
                            <ul class='dropdown-menu'>
                                <li>&nbsp;相关的商品个体</li>
                                <li class='divider'></li>
                                {% for itemNO in ivtQtyObj['itemNOs'] %}
                                <li>{{ itemNO }}</li>
                                {% endfor %}
                            </ul>
                        </div>
                        ({{ ivtQtyObj.name }})<br/>
                        {%- endfor %}
                    </td>
                    <td>{{ dtl.realPrice }}</td>
                    <td>{{ dtl.realFee }}</td>
                    <td>{{ dtl.realAmount }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class='row'>
        {{mymacros.render_system_info(so)}}
    </div>
</div>
{% endblock %}